//
//  HNMgrComplainController.m
//  XDEducation
//
//  Created by 星道 on 17/5/23.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HNMgrComplainController.h"

@interface HNMgrComplainController ()<UITextViewDelegate>
{
    IBOutlet UITextView *_TextView;
    UILabel *_placeHolder;
    IBOutlet UILabel *_ContentTitle;
}
@end

@implementation HNMgrComplainController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _TextView.delegate = self;
    
    [self SetPlaceHolder];
    _ContentTitle.text = self.Content;

}





#pragma mark - Function
- (void)SetPlaceHolder
{
    
    UILabel *placeHolder = [[UILabel alloc] initWithFrame:CGRectMake(15, -5, _TextView.frame.size.width-30, 50)];
    _placeHolder = placeHolder;
    placeHolder.text = @"回复内容";
    placeHolder.textColor = [UIColor lightGrayColor];
    placeHolder.numberOfLines = 0;
    placeHolder.font = [UIFont systemFontOfSize:14];
    placeHolder.contentMode = UIViewContentModeTop;
    [_TextView addSubview:placeHolder];
}


#pragma mark - TextView代理
- (void)textViewDidChange:(UITextView *)textView
{
    if (textView.text.length <= 0)
    {
        _placeHolder.hidden = NO;
    }
    else
    {
        _placeHolder.hidden = YES;
    }
}




/** 回复 */
- (IBAction)Answer:(id)sender
{
    if (_TextView.text.length <= 0)
    {
        [MBProgressHUD showError:@"请填写回复信息"]; return;
    }
    
    [MBProgressHUD showHUD];
    NSDictionary *Dict = @{
                           @"id":self.ID,
                           @"handleResult":_TextView.text
                           };
    
    [XDHttpTool post:BaseURL(@"user.do?action=replyAppeal") authCode:[AccountTool shareAccountTool].currentAccount.authCode params:Dict success:^(id responseObj) {
        [MBProgressHUD showError:responseObj[@"msg"]];
        if ([responseObj[@"code"] isEqualToNumber:@1000])
        {
            if (self.AnswerOk)
            {
                self.AnswerOk ();
            }
            [self.navigationController popViewControllerAnimated:YES];
        }
        
    } failure:^(NSError *error) {
        [MBProgressHUD showError:XDNetWorkError];

    }];
}

@end
